from django.db import models
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

# Create your models here.
class Host(models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=255)
    email = models.EmailField()
    status = models.IntegerField()

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('host-detail', args=[self.id])
    
    class Meta:
        ordering = ["name"]
        verbose_name="User host"
        verbose_name_plural = "User hosts"

class HostAlias(models.Model):
    host = models.ForeignKey(Host)
    name = models.CharField(max_length=255)

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('delete-host-alias', args=[self.host.id, self.id])
    
    class Meta:
        ordering = ["name"]
